<template>
  <div>
    <plan-header ref="planHeader" :tableData="tableData" :openDate="$route.query.openDate" :management="true" />
    <otherPlanBody :tableBody="tableBody" :planDocDataId="docDataId" :docClassId="docClassId" />
  </div>
</template>

<script>
  import {honorReword,getContent} from "@/api/plan.js"
  import planHeader from "@/components/plan/planHeader.vue"
  import otherPlanBody from "@/components/plan/otherPlanBody.vue"
  export default {
    components: {
      planHeader,
      otherPlanBody,
    },
    data() {
      return {
        docClassId: '',
        docDataId: '',
        tableData: {},
        tableBody: [],
      }
    },
    created() {
      this.docDataId = this.$route.query.docDataId
      this.getPlanData()
    },
    methods: {
      getPlanData() {
        if(this.docDataId) {
          getContent({docDataId:this.docDataId}).then(res=>{
            if(res.code === 200) {
              this.tableData = res.data
              this.tableData.parentId = this.docDataId
              this.docClassId = res.data.planTypeId
              this.tableBody = res.data.tableBody
            }else{
              this.$message.error(res.message)
            }
          })
        }else{
          honorReword().then(res=>{
            if(res.code === 200) {
              this.tableData = res.data
              this.docClassId = res.data.planTypeId
              this.tableBody = res.data.tableBody
            }else{
              this.$message.error(res.message)
            }
          })
        }
      }
    },
  }
</script>

<style scoped>

</style>
